package com.seecen.controller;

import com.seecen.common.BaseResponse;
import com.seecen.pojo.dto.AdminLoginDTO;
import com.seecen.pojo.dto.AdminRegDTO;
import com.seecen.pojo.dto.UserDto;
import com.seecen.pojo.dto.UserReg;
import com.seecen.pojo.entity.User;
import com.seecen.pojo.vo.AdminLoginVO;
import com.seecen.pojo.vo.AdminRegVO;
import com.seecen.service.UserService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;
    @PostMapping("login")
    public BaseResponse login(@RequestBody UserDto userDto) {
        return userService.login(userDto);
    }
    @PostMapping("register")
    public BaseResponse register(@RequestBody UserReg userReg) {
        return userService.register(userReg);
    }

    @PutMapping("reset")
    public BaseResponse resetAccount(@RequestBody UserDto userDto) {
        log.info("接收密码重置请求：用户名={}", userDto.getUserAccount());
        BaseResponse ret = userService.resetAccount(userDto);
        log.info("密码重置结果：{}", ret);
        return ret;
    }

    @DeleteMapping("/delete/{userId}")
    public BaseResponse deleteAccount(@PathVariable Long userId) {
        return userService.deleteAccount(userId);
    }

    @PostMapping("/admin/login")
    public BaseResponse<AdminLoginVO> adminLogin(@RequestBody AdminLoginDTO adminLoginDTO) {
        return userService.getAdminLogin(adminLoginDTO);
    }

    @PostMapping("/admin/register")
    public BaseResponse<AdminRegVO> adminRegister(@RequestBody AdminRegDTO adminRegDTO) {
        return userService.getAdminRegister(adminRegDTO);
    }




}
